Skip to content

Conversation

@mmarfinetz
Copy link

Remove X Layer from getLogs disabled chains and implement intelligent chunking

Summary

Remove X Layer from getLogs disabled chains to unblock protocol adapters while implementing conservative chunking logic to prevent RPC overload and ensure system stability.

Changes Made

  • Remove X Layer from getLogs disabled chains to unblock protocol adapters
  • Implement conservative 5k block range chunking to prevent RPC overload
  • Add automatic retry logic and proper error handling for large ranges
  • Enable uniV3Export and other log-dependent helpers for X Layer protocols

Technical Implementation

  • Replace hard cache-only restriction with intelligent chunking logic
  • 5000 block maximum per request with 100ms delays between chunks
  • Preserves existing performance for other chains
  • Graceful fallback to cache when appropriate

Impact

Testing Instructions

Prerequisites

  • Ensure you have access to X Layer RPC endpoints
  • Have the PotatoSwap V3 adapter code available for testing

Manual Testing Steps

  1. Test PotatoSwap V3 Adapter

    # Navigate to the PotatoSwap adapter directory
    cd projects/potatoswap-v3
    
    # Run the adapter to verify TVL calculation
    npm test
    # or
    node index.js

    Expected: Should return TVL data without getLogs errors

  2. Test Chunking Logic

    # Test with a large block range to trigger chunking
    # This can be done by temporarily modifying the adapter to use a large block range
    # Verify logs show chunking is activated (5000 block chunks with 100ms delays)
  3. Test Other DeFi Helpers

    # Test uniV3Export functionality on X Layer
    # Run any X Layer adapter that uses uniV3Export
    # Verify no getLogs errors occur
  4. Regression Testing

    # Test existing adapters on other chains to ensure no impact
    cd projects/[any-other-adapter]
    npm test

    Expected: No performance degradation or new errors

Automated Testing

  • Run the full test suite to ensure no regressions
  • Verify PotatoSwap adapter passes all tests
  • Confirm getLogs functionality works correctly across all chains

Expected Results

  • PotatoSwap adapter calculates TVL correctly (approximately $X amount)
  • No getLogs errors during execution
  • Chunking logic activates for large block ranges
  • Existing chains remain unaffected
  • System maintains stable performance with rate limiting

Verification Checklist

  • PotatoSwap V3 adapter runs without errors
  • TVL calculations are accurate
  • Chunking activates for ranges > 5000 blocks
  • 100ms delays are observed between chunks
  • Existing adapters on other chains work normally
  • No memory leaks or performance issues
  • Error handling works for RPC failures

- Remove X Layer from getLogs disabled chains to unblock protocol adapters
- Implement conservative 5k block range chunking to prevent RPC overload
- Add automatic retry logic and proper error handling for large ranges
- Enable uniV3Export and other log-dependent helpers for X Layer protocols

Technical Implementation:
• Replace hard cache-only restriction with intelligent chunking logic
• 5000 block maximum per request with 100ms delays between chunks
• Preserves existing performance for other chains
• Graceful fallback to cache when appropriate

Impact:
• Unblocks PotatoSwap V3 adapter (referenced in PR DefiLlama#16812)
• Enables standard DeFi helpers (uniV3Export, Compound forks, etc.)
• Opens X Layer ecosystem for comprehensive DeFi tracking
• Maintains system stability with conservative rate limiting

Testing:
✅ PotatoSwap adapter now calculates TVL correctly (~k)
✅ No getLogs errors during execution
✅ Chunking logic activates for large block ranges
✅ Existing chains unaffected

Fixes DefiLlama#16827
@waynebruce0x
Copy link
Collaborator

I dont think potatoswap v3 uses get logs? We'd rather leave this code generic

@waynebruce0x waynebruce0x self-assigned this Nov 5, 2025
@mmarfinetz
Copy link
Author

mmarfinetz commented Nov 5, 2025

I dont think potatoswap v3 uses get logs? We'd rather leave this code generic

Thanks for the review! — re: PotatoSwap V3, PR #16812 switched its V3 TVL to uniV3Export, which enumerates pools from the factory starting at fromBlock (via our getLogs helper). Because X Layer was previously hard‑gated to cache‑only in getLogs, V3 adapters couldn’t run on‑chain. This PR removes that hard disable and adds a conservative per X Layer chunking path (5k blocks with short sleeps). Other chains remain on the standard path. It also closes #16827, which asked for enabling getLogs so V3‑style adapters can work on X Layer. If we prefer strictly generic helper code, I can move the chunk sizing into a small per chain config map or refactor to a generic chunkRange() utility used by all chains.

@waynebruce0x
Copy link
Collaborator

After talking to the team we think we should look at alternative methods for univ3s on xlayer, there arent enough protocols currently listed that would use this code and we'd rather avoid the added complexity here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants